/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;
import oracle.jdbc.pool.OracleDataSource;

/**
 *
 * @author p1104123
 */
public class ConnexionBDOracle {

    public static Connection getConnection() {
        try {
            Properties props = new Properties();
            FileInputStream fichier = new FileInputStream("src/connexion.properties");
            props.load(fichier);
            OracleDataSource ods = new OracleDataSource();
            ods.setDriverType(props.getProperty("pilote"));
            ods.setPortNumber(new Integer(props.getProperty("port")).intValue());
            ods.setServiceName(props.getProperty("service"));
            ods.setUser(props.getProperty("user"));
            ods.setPassword(props.getProperty("pwd"));
            ods.setServerName(props.getProperty("serveur"));
            System.out.print("\nConnexion reussie");
            return ods.getConnection();
        } 
        catch (Exception e) {
            System.out.print("\n Problème de connexion" +e.getMessage());
            return null;
        }
    }
}
